package util
{
	import mx.core.UIComponent;
	import mx.effects.Move;
	import mx.events.EffectEvent;
	
	public class Vibrate
	{
		public var displayObj:UIComponent = new UIComponent();
		public function Vibrate(displayObj:UIComponent)
		{
			this.displayObj = displayObj;
		}
		
		// micro vibrate
		public function microVibrate(x:Number, y:Number):void{
			var vibrator:Move = new Move(displayObj);
			vibrator.end();
			vibrator.duration = 100;
			vibrator.xTo = x-6;
			vibrator.repeatCount = 2;
			vibrator.play(null,true);
			/** alternative
			vibrator.play();
			vibrator.end();
			vibrator.startDelay = 10;
			vibrator.xTo = x+6;
			vibrator.play();
			vibrator.end();
			vibrator.startDelay = 10;
			vibrator.xTo = x;
			vibrator.play(); */
		}
		
		public function shake(displayObj:UIComponent):void{
            var shake:Move = new Move(displayObj);
            shake.end();
            //移动的时间，0.1毫秒
            shake.duration = 100;
            //设定抖动位移
            shake.xTo = displayObj.x-6;
            //两次抖动
            shake.repeatCount = 2;
            //第一个参数是targets,如果想让一组UIComponent抖动，就要添加到targets数组中
            //第二个参数是是否移动到位置之后再返回playReverseFromEnd
            shake.play(null,true);
        }

	}
}
